package com.sportsforce.client.map;

import com.google.gwt.maps.client.InfoWindow;
import com.google.gwt.maps.client.InfoWindowContent;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.event.MarkerClickHandler;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.overlay.Marker;
import com.sportsforce.client.twitter.TweetEntity;

/** 
 * Mark the map with the tweet locations and texts.
 * 
 * @MainFeature 
 */

public class MapPointers {

	public MapPointers(final MapWidget map, final TweetEntity tweet) {

		LatLng us = LatLng.newInstance(tweet.getLatitude(),
				tweet.getLongitude());

		final Marker usMarker = new Marker(us);

		// usMarker.setImage(url);

		usMarker.addMarkerClickHandler(new MarkerClickHandler() {
			public void onClick(MarkerClickEvent event) {
				InfoWindow info = map.getInfoWindow();
				info.open(usMarker, new InfoWindowContent(tweet.getTweetText()));
			}
		});

		map.addOverlay(usMarker);
	}
}
